import {BrowserWindow,remote} from 'electron'
import {winURL} from '../../setting'

function createWindow(browserWindow, url) {
    if (!url)
        url = winURL
    /**
     * Initial window options
     */
    let win = new browserWindow({
        height: 600,
        width: 800,
        useContentSize: true,

    })

    win.loadURL(url)
    win.maximize()
    win.on('closed', () => {
        win = null
    })

    return win
}

/**
 * 创建主窗口
 */
export function createMainWindow() {
    return createWindow(BrowserWindow)
}

/**
 * 打开一个新窗口
 * @param winURL 内容页面，为空则打开默认页
 */
export function createRemoteWindow(url) {
    return createWindow(remote.BrowserWindow, url)
}